﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BussinessLogic;
using DataAccess;

namespace WSS.hameduconn
{
    public partial class Site : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsAuthenticated)
            {
                divUser.Visible = true;
                lblCurrentUser.Text = AuthenticateInfo.admin != null ? AuthenticateInfo.admin.Username : AuthenticateInfo.user.Username;
                if (AuthenticateInfo.admin != null)
                {
                    divMenu.Visible = true;
                    liChangeProfile.InnerHtml = "<a href=\"AdminProfile.aspx\">Change profile</a>";
                }
                else
                {
                    divMenu.Visible = false;
                    liChangeProfile.InnerHtml = "<a href=\"Profile.aspx\">Change profile</a>";
                }
            }
            else
            {
                divUser.Visible = false; 
                divMenu.Visible = false;
            }
        }
        public Authenticate AuthenticateInfo
        {
            get
            {
                if (IsAuthenticated)
                    return ((Authenticate)Session["OAuth"]);
                return null;

            }
        }
        public bool IsAuthenticated
        {
            get
            {
                if (Session["OAuth"] == null)
                    return false;
                return true;

            }
        }
    }
}